home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 147_01 / catalog.dsk < prev    next >
Text File  |  1985-03-09  |  11KB  |  472 lines

  1. );    
  2. }
  3. /****************************************************************/
  4. nu_user()
  5. {
  6.     int    fd;
  7.  
  8.     outstr("Creating new USERS.CCC...",2);
  9.     unlink(DSK(USERS.CCC));
  10.     if ( (fd = creat(DSK(USERS.CCC))) == ERROR)
  11.         ioerr("Creating USERS.CCC");
  12.     formrec(tmpstr,SECSIZ);
  13.     sprintf(tmpstr+NM,"%s","SYSOP");    /* NM:    */
  14.     sprintf(tmpstr+PRV,"%c%c",'!',0);    /* PRV:    */
  15.     sprintf(tmpstr+UBL,"%1d",FALSE);    /* UBL:    */
  16.     sprintf(tmpstr+UXP,"%1d",TRUE);        /* UXP:    */
  17.     sprintf(tmpstr+PWD,"%s","123456");    /* PWD:    */
  18.     sprintf(tmpstr+LLG,"%s",sysdate);    /* LLG:    */
  19.     sprintf(tmpstr+FRM,"%s",SYSITE);    /* FRM:    */
  20.     sprintf(tmpstr+LMG0,"%03d",0);        /* LMG0:*/
  21.     sprintf(tmpstr+LMG1,"%03d",0);        /* LMG1:*/
  22.     sprintf(tmpstr+LMG2,"%03d",0);        /* LMG2:*/
  23.     sprintf(tmpstr+LMG3,"%03d",0);        /* LMG3:*/
  24.     sprintf(tmpstr+LMG4,"%03d",0);        /* LMG4:*/
  25.     sprintf(tmpstr+LMG5,"%03d",0);        /* LMG5:*/
  26.     sprintf(tmpstr+LMG6,"%03d",0);        /* LMG6:*/
  27.     Rriterec(fd,1,1,tmpstr);
  28.  
  29.     formrec(tmpstr,SECSIZ);
  30.     sprintf(tmpstr,"MAX REC: %3d",1);
  31.     Rriterec(fd,0,1,tmpstr);
  32.     close(fd);
  33. }
  34. /****************************************************************/
  35. rite_user(u)
  36. struct    _user    *u;
  37. {
  38.     int    i,j,k;
  39.     int     auto;
  40.     int    fdin,fdout;
  41.     int    inct,outct;
  42.  
  43.     outct = 1;
  44.     auto = FALSE;
  45.     if ( getyn("Write deleted records w/o asking"))
  46.         auto = TRUE;
  47.     if ( (fdin = open(DSK(USERS.CCC),2)) == ERROR)
  48.         ioerr("Cannot open USERS.CCC");
  49. #if    LOCKEM
  50.     if (lokrec(fdin,-1))
  51.         ioerr("locking USERS.CCC");
  52. #endif
  53.     if ((fdout= creat(DSK(USERS.$$$)))== ERROR)
  54.         ioerr("Creating USERS.$$$ file");
  55.     if ( seek(fdout,1,0) == ERROR)
  56.         ioerr("Seek in USERS.$$$");
  57.     readrec(fdin,0,tmpstr,1);
  58.     sscanf(tmpstr,"MAX REC: %d",&inct);
  59.     for ( i = 1; i <= inct; i++)
  60.     {
  61.         formrec(tmpstr,SECSIZ);
  62.         readrec(fdin,i,tmpstr,1);
  63.         sscanf(tmpstr+NM,"%s",u->nm);        /* NM:    */
  64.         sscanf(tmpstr+LLG,"%s",u->lastlog);    /* LLG:    */
  65.         sscanf(tmpstr+FRM,"%s",u->from);    /* FRM:    */
  66.         sscanf(tmpstr+PRV,"%s",u->ustat);    /* PRV: */
  67.         if (auto && (*(u->ustat) != '#'))/* GOODBYE TWITS*/
  68.         {
  69.             printuser(u);
  70.             Rriterec(fdout,outct++,1,tmpstr);
  71.         }
  72.         if (!auto)
  73.         {
  74.             printuser(u);
  75.             crlf(1);
  76.             if ( getyn("Write rec"))
  77.             {
  78.                 Rriterec(fdout,outct++,1,tmpstr);
  79.             }
  80.         }
  81.     }
  82.     formrec(tmpstr,SECSIZ);
  83.     sprintf(tmpstr,"MAX REC: %d",--outct);
  84.     Rriterec(fdout,0,1,tmpstr);
  85.     if ( close(fdout) == ERROR)
  86.         ioerr("Closing USERS.$$$");
  87.  
  88. #if    LOCKEM
  89.     frerec(fdin,-1);
  90. #endif
  91.     if ( close(fdin) == ERROR)
  92.         ioerr("Closing USERS.CCC");
  93.     unlink(DSK(USERS.BAK));
  94.     if ( rename(DSK(USERS.CCC),DSK(USERS.BAK)) == ERROR)
  95.         ioerr("Renaming USERS.CCC to USERS.BAK");
  96.     if ( rename(DSK(USERS.$$$),DSK(USERS.CCC)) == ERROR)
  97.         ioerr("Renaming USERS.$$$ to USERS.CCC");
  98. }
  99. /****************************************************************/
  100. #if    !PERSONLY
  101. subject()
  102. {
  103.     int    i,fd,n;
  104.  
  105.     crlf(1);
  106.     if ( (fd = open(DSK(SUBJECTS.CCC),2)) == ERROR)
  107.         fd = creat_subj(fd);
  108.     if ( readrec(fd,0,tmpstr,1) == ERROR)
  109.         ioerr("reading the subject record");
  110.     sscanf(tmpstr,"%d",&n);
  111.     displ_subj(fd,n,tmpstr);
  112.     close(fd);    
  113. }
  114. /****************************************************************/
  115. creat_subj(fd)
  116. int    fd;
  117. {
  118.     int    i;
  119.  
  120.     outstr("Creating new SUBJECTS.CCC...",1);
  121.     if ( (fd = creat(DSK(SUBJECTS.CCC))) == ERROR)
  122.         ioerr("creating SUBJECTS.CCC");
  123.     for ( i = 0; i < SECSIZ; i++)
  124.         *(tmpstr+i) = ' ';
  125.     sprintf(tmpstr,"%02d",2);
  126.     sprintf(tmpstr+8,"PERSONAL");
  127.     sprintf(tmpstr+16,"GENERAL ");
  128.     Rriterec(fd,0,1,tmpstr);
  129.     return fd;
  130. }
  131. /****************************************************************/
  132. add_subj()
  133. {
  134.     int    i,fd,n;
  135.     char    input[17];
  136.     char    rec[SECSIZ];
  137.  
  138.     if ( (fd = open(DSK(SUBJECTS.CCC),2)) == ERROR)
  139.         ioerr("opening subject");
  140. #if    LOCKEM
  141.     if (lokrec(fd,-1))
  142.         ioerr("locking SUBJECTS.CCC");
  143. #endif
  144.     if ( readrec(fd,0,rec,1) == ERROR)
  145.         ioerr("reading the subject record");
  146.     sscanf(rec,"%d",&n);
  147.     displ_subj(fd,n,rec);
  148.         do
  149.         {
  150.         outstr("Enter new subject <Max 8 chars>: ",4);
  151.         instr("",input,8);
  152.         capstr(input);
  153.         } while (!strlen(input));
  154.     strcat(input,"        ");
  155.     sprintf(rec+8*(++n),"%8.8s",input);
  156.     sprintf(rec,"%02d",n);
  157.     Rriterec(fd,0,1,rec);
  158. #if    LOCKEM
  159.     frerec(fd,-1);
  160. #endif
  161.     close(fd);    
  162. }
  163. /****************************************************************/
  164. select_subj(choice,s)
  165. int    choice;
  166. struct    _sum    *s;
  167. {
  168.     int    fd,n;
  169.     char    input[3];
  170.     char    rec[SECSIZ];
  171.  
  172.     if ( (fd = open(DSK(SUBJECTS.CCC),2)) == ERROR)
  173.         ioerr("opening SUBJECTS.CCC");
  174.     if (readrec(fd,0,rec,1) == ERROR)
  175.         ioerr("reading SUBJECTS.CCC");
  176.     sscanf(rec,"%d",&n);
  177.     if (!choice)
  178.     {
  179.         outstr("Subjects are:",2);
  180.         displ_subj(fd,n,rec);
  181.         outstr("File number: ",4);
  182.         instr("",input,3);
  183.         crlf(1);
  184.         choice = atoi(input);
  185.     }
  186.     setmem(cmsgfile,9,0);
  187.     movmem(rec+8*choice,cmsgfile,8);
  188.     sprintf(msgfile,"%s%s%s",DRIVE,capstr(cmsgfile),".MSG");
  189.     sprintf(tmpstr,"Current SUBJECT File: %s",msgfile);
  190.     outstr(tmpstr,2);
  191.     crlf(1);
  192.     close(fd);    
  193. }
  194. #endif
  195. /****************************************************************/
  196. superuser()
  197. {
  198.     char    name[NAMELGTH+1];
  199.     char    input[5];
  200.     struct    _user    u2;
  201.     int    ufd;
  202.     int    i;
  203.  
  204.     if ( (ufd = open(DSK(USERS.CCC),2)) == ERROR)
  205.         ioerr("opening USERS");
  206.     crlf(1);
  207. #if    LOCKEM
  208.     if (lokrec(ufd,-1))
  209.         ioerr("locking USERS");
  210. #endif
  211.     while ( (getname(name,"Enter user name: ")) )
  212.         crlf(1);
  213.     if (!checkuser(ufd,name,u2,0))
  214.     {
  215.         crlf(1);
  216.         if (getyn("User not found.  Add this user") )
  217.         {
  218.             belflg = FALSE;
  219.             expert = FALSE;
  220.             newuser(u2,name,ufd);
  221.         }
  222. #if    LOCKEM
  223.         frerec(ufd,-1);
  224. #endif
  225.         close(ufd);
  226.         return;
  227.     }
  228.     else
  229.     {
  230.         printuser(u2);
  231.         for ( i = 2; i <= 8; ++i)
  232.         {
  233.     sprintf(tmpstr,"Last msg (File #%d): %d, change it",i,u2.lstmsg[i-2]);
  234.             while(getyn(tmpstr))
  235.             {
  236.                 outstr("Enter new value: ",5);
  237.                 instr("",input,4);
  238.                 u2.lstmsg[i-2] = atoi(input);
  239.     sprintf(tmpstr,"Last msg (File #%d): %d, change it",i,u2.lstmsg[i-2]);
  240.                 crlf(1);
  241.             }
  242.         }
  243.         sprintf(tmpstr,"MF stat: %s, change it",u2.ustat);
  244.         while(getyn(tmpstr))
  245.         {
  246.             outstr("Enter new value: ",5);
  247.             instr("",u2.ustat,1);
  248.             sprintf(tmpstr,"MF stat: %s, change it",u2.ustat);
  249.             crlf(1);
  250.         }
  251.         sprintf(tmpstr,"Password: %s, change it",u2.pwd);
  252.         while(getyn(tmpstr))
  253.         {
  254.             outstr("Enter: ",5);
  255.             instr("",u2.pwd,6);
  256.             sprintf(tmpstr,"Password: %s, change it",u2.pwd);
  257.             crlf(1);
  258.         }
  259.         belflg = u2.bellflag;
  260.         expert = u2.xpert;
  261.         updtuser(u2,ufd);
  262.     }
  263. #if    LOCKEM
  264.     frerec(ufd,-1);
  265. #endif
  266.     close(ufd);
  267. }
  268. /****************************************************************/
  269. printuser(u)
  270. struct    _user    *u;
  271. {
  272.     char    temp[SECSIZ];
  273.  
  274.     crlf(1);
  275.     sprintf(temp,"USER NAME:  %s",u->nm);
  276.     outstr(temp,3);
  277.     sprintf(temp,"USER SITE:  %s",u->from);
  278.     outstr(temp,3);
  279.     sprintf(temp,"LAST LOGON: %s",u->lastlog);
  280.     outstr(temp,2);
  281.     crlf(1);
  282. }
  283. /****************************************************************/
  284. newuser(u,name,fd)        /*DOUBLE CHECKS NEW USER & GETS    */
  285. struct    _user    *u;        /*INFO TO ADD NEW USER. ADDS    */
  286. char    *name;            /*NEW USER TO FILE. DOES NOT    */
  287. int    fd;            /*CLOSE USER FILE        */
  288. {
  289.     int    correct;
  290.     char    place[31];
  291.     char    passwd[7];
  292. #if    LOCKEM
  293.     char    temp[SECSIZ];
  294. #endif
  295.  
  296.     correct = FALSE;
  297.     crlf(1);
  298.     do
  299.     {
  300.         sprintf(tmpstr,"Enter user's %s: ",SITEPROMPT);
  301.         outstr(tmpstr,4);
  302.         instr("",place,30);
  303.         capstr(place);
  304.         crlf(1);
  305.         sprintf(tmpstr,"Is the name, %s, correct",place);
  306.         correct = getyn(tmpstr);
  307.     }while(!correct);
  308.     chkpwd(passwd);
  309.  
  310.     formrec(tmpstr,SECSIZ);
  311.     sprintf(tmpstr+NM,"%s",name);        /* NM:    */
  312.     sprintf(tmpstr+PRV,"%c%c",'+',0);    /* PRV:    */
  313.     sprintf(tmpstr+UBL,"%1d",belflg);    /* UBL:    */
  314.     sprintf(tmpstr+UXP,"%1d",expert);    /* UXP:    */
  315.     sprintf(tmpstr+PWD,"%s",passwd);    /* PWD:    */
  316.     sprintf(tmpstr+LLG,"%s",logdate);    /* LLG:    */
  317.     sprintf(tmpstr+FRM,"%s",place);        /* FRM:    */
  318.     sprintf(tmpstr+LMG0,"%03d",0);        /* LMG0:*/
  319.     sprintf(tmpstr+LMG1,"%03d",0);        /* LMG1:*/
  320.     sprintf(tmpstr+LMG2,"%03d",0);        /* LMG2:*/
  321.     sprintf(tmpstr+LMG3,"%03d",0);        /* LMG3:*/
  322.     sprintf(tmpstr+LMG4,"%03d",0);        /* LMG4:*/
  323.     sprintf(tmpstr+LMG5,"%03d",0);        /* LMG5:*/
  324.     sprintf(tmpstr+LMG6,"%03d",0);        /* LMG6:*/
  325. #if    LOCKEM
  326.     formrec(temp,SECSIZ);
  327.     if (lokrec(fd,-1))
  328.         ioerr("l